from selenium.webdriver.common.by import By

from web_practice.wework_po.page_object.base_page import BasePage
from web_practice.wework_po.utils.log_util import logger


class AddMemberPage(BasePage):
    _INPUT_USERNAME = By.ID, "username"
    _INPUT_ACCOUNT = By.ID, "memberAdd_acctid"
    _INPUT_PHONE = By.ID, "memberAdd_phone"
    _BNT_SAVE = (By.CSS_SELECTOR, ".js_btn_save")
    def fill_info(self,name,phonenum,account):
        # 1. 填写姓名
        # 2. 填写帐号
        # 3. 填写手机号
        # 4. 点击保存
        logger.info("点击填写成员信息")
        logger.info("输入用户名")
        self.find_and_send(name, self._INPUT_USERNAME)
        logger.info("输入帐号")
        self.find_and_send(account, self._INPUT_ACCOUNT)
        logger.info("输入手机号")
        self.find_and_send(phonenum, self._INPUT_PHONE)
        logger.info("点击保存")
        # 只找第一个元素，找到就返回。
        self.find_and_click(self._BNT_SAVE)
        from web_practice.wework_po.page_object.contact_page import ContactPage
        return ContactPage(self.driver)